package com.example.demo_actionbar_tab;


import java.util.ArrayList;

import android.app.Activity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import com.example.demo_actionbar_tab.R;
public class adapter_grid extends ArrayAdapter<Truyen>
{
	private Context context;
	private int layoutRow;
	private ArrayList<Truyen> data=null;
	private ImageView img;
	private TextView txt;
	
	public adapter_grid(Context context, int layoutRow, ArrayList<Truyen> data) {
		super(context,layoutRow,data);
		// TODO Auto-generated constructor stub
		this.context=context;
		this.layoutRow=layoutRow;
		this.data=data;
		
	}
	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		View view=convertView;
		if(view==null)
		{
			LayoutInflater inflate=((Activity)context).getLayoutInflater();
			view=inflate.inflate(layoutRow, parent, false);
			img=(ImageView) view.findViewById(R.id.img_bia);
			txt=(TextView) view.findViewById(R.id.txt_tentruyen);
						
			img.setImageResource(data.get(position).getBiaTruyen());
			txt.setText(data.get(position).getTenTruyen());
			
		}
		return view;
	}
		
		
	

}
